var scanCodeDebug = function () {
    $(".barcodeField").val('7290004131074');
    Wicket.Ajax.ajax({"u": "${callbackUrl}", "e": "click"});

};

var scanCode = function (callBackUrl) {
    var duration = 10000;
    window.plugins.barcodeScanner.scan(
        function (result) {
            Wicket.Ajax.get({u: callBackUrl + "&barcode=" + result.text});
        }, function (error) {
//            console.debug("Scan failed: " + error);
        });
};

var encodeText = function (cartDetails) {
    window.plugins.barcodeScanner.encode(BarcodeScanner.Encode.TEXT_TYPE, cartDetails,
        function (success) {
            $("#qrBarcodePopup").popup("open");
//            alert("Encode success: " + success);
        }, function (fail) {
//            alert("Encoding failed: " + fail);
        });
};

var encodeEmail = function () {
    window.plugins.barcodeScanner.encode(
        BarcodeScanner.Encode.EMAIL_TYPE,
        "a.name@gmail.com", function (success) {
            alert("Encode success: " + success);
        }, function (fail) {
            alert("Encoding failed: " + fail);
        });
}

var encodePhone = function () {
    window.plugins.barcodeScanner.encode(
        BarcodeScanner.Encode.PHONE_TYPE,
        "555-227-5283", function (success) {
            alert("Encode success: " + success);
        }, function (fail) {
            alert("Encoding failed: " + fail);
        });
}

var encodeSMS = function () {
    window.plugins.barcodeScanner.encode(
        BarcodeScanner.Encode.SMS_TYPE,
        "An important message for someone.", function (success) {
            alert("Encode success: " + success);
        }, function (fail) {
            alert("Encoding failed: " + fail);
        });
}